<script setup lang="ts">
import { Button, ClButton } from "@chulei-ui/components";
import { ElMessage } from "@chulei-ui/element-plus";
import { useAuth } from "../../../auth/use-auth";
import { emitter } from "../../../bus";
const { getAuthCode, getRefreshToken } = useAuth();

const auth = async () => {
  const code = await getAuthCode();
  await getRefreshToken(code!);
  emitter.emit("auth-success");
  ElMessage.success("授权成功");
};

defineOptions({
  name: "GrantAuthButton",
});
</script>

<template>
  <cl-button :type="Button.Type.primary" :size="Button.Size.small" @click="auth">授权</cl-button>
</template>

<style scoped lang="scss"></style>
